# Maintainer: ungleich <alpinelinux@ungleich.ch>
pkgname=prometheus-blackbox-exporter
_pkgname=blackbox_exporter
pkgver=0.25.0
pkgrel=3
pkgdesc="Prometheus Blackbox Exporter"
url="https://github.com/prometheus/blackbox_exporter"
license="Apache-2.0"
arch="all"
install="$pkgname.pre-install"
makedepends="go"
provides="blackbox_exporter=$pkgver-r$pkgrel"
replaces="blackbox_exporter"
source="
	$_pkgname-$pkgver.tar.gz::https://github.com/prometheus/blackbox_exporter/archive/v$pkgver.tar.gz
	blackbox-exporter.confd
	blackbox-exporter.initd
"
builddir="$srcdir/$_pkgname-$pkgver"
subpackages="$pkgname-openrc"

# secfixes:
#   0.18.0-r0:
#     - CVE-2020-16248

export GOCACHE="${GOCACHE:-"$srcdir/go-cache"}"
export GOTMPDIR="${GOTMPDIR:-"$srcdir"}"
export GOMODCACHE="${GOMODCACHE:-"$srcdir/go"}"

build() {
	go build
}

check() {
	go test
}

package() {
	# dirs
	install -dm755 "$pkgdir"/etc/prometheus

	# init
	install -Dm755 blackbox_exporter \
		"$pkgdir"/usr/bin/blackbox_exporter
	install -Dm755 "$srcdir"/blackbox-exporter.initd \
		"$pkgdir"/etc/init.d/blackbox-exporter
	install -Dm644 "$srcdir"/blackbox-exporter.confd \
		"$pkgdir"/etc/conf.d/blackbox-exporter

	# config
	install -Dm644 blackbox.yml \
		"$pkgdir"/etc/prometheus/blackbox.yml
}

sha512sums="
86edb5c6aac213c5d5821ee58233a72043ac6abe5c5b2a8695f33160127d7126ab27de1d83fdd99d3053447efae41d2ba260bff7c84687dcea30df6439970630  blackbox_exporter-0.25.0.tar.gz
2aadbcf2d1fa18650dbc930f9b09ad786f537e8d8525568c016e240798b3db60606f95cf949d75bb797dd9e02d3f07e24e87ee7a420280eec9a326e1455f261d  blackbox-exporter.confd
9e69c8804657e01f9346cab5845c933c1e2eefc2a9a33054d484b50b0c1848ee27c5759876c51194c2374aac84d3c88c13fc41be438eebaf1ce618f51edd0263  blackbox-exporter.initd
"
